﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;

namespace sltnLogin
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnEntrar_Click(object sender, EventArgs e)
        {
            DataTable dt = Conexao.getInstance.executeQuery("Select 1 from usuario where usuario = '" + txtbxLogin.Text + "' and senha = '" + txtbxSenha.Text + "'");
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Usuário/Senha inválidos!", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            this.Visible = false;
            frmCompras f = new frmCompras();
            f.ShowDialog();
            this.Visible = true;
            txtbxLogin.Text = "";
            txtbxSenha.Text = "";
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            cmbxModulo.SelectedIndex = 0;
        }
    }
}
